package com.wrupple.vegetate.client.domain;

import java.util.List;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayString;
import com.wrupple.vegetate.client.util.JsArrayList;
import com.wrupple.vegetate.domain.FieldDescriptor;

public final class JsFieldDescriptor extends JavaScriptObject implements
		FieldDescriptor {

	protected JsFieldDescriptor() {
		super();
	}

	@Override
	public native boolean isSummary() /*-{
		return this.summary;
	}-*/;

	@Override
	public native String getId() /*-{
		if(this.id==null){
			return null;
		}
		return String(this.id);
	}-*/;

	@Override
	public native String getName() /*-{
		return this.name;
	}-*/;

	@Override
	public native String getWidget() /*-{
		return this.widget;
	}-*/;

	@Override
	public native boolean isFilterable() /*-{
		return this.filterable;
	}-*/;

	@Override
	public native boolean isCreateable() /*-{
		return this.createable;
	}-*/;

	@Override
	public native boolean isWriteable() /*-{
		return this.writeable;
	}-*/;

	@Override
	public native boolean isEditable() /*-{
		return this.editable;
	}-*/;

	@Override
	public native boolean isDetailable() /*-{
		return this.detailable;
	}-*/;

	@Override
	public native String getDefaultValue() /*-{
		return this.defaultValue;
	}-*/;

	@Override
	public native String getForeignCatalog() /*-{
		return this.foreignCatalog;
	}-*/;

	@Override
	public native boolean isKey() /*-{
		return this.key;
	}-*/;

	@Override
	public List<String> getDefaultValueOptions() {
		return JsArrayList
				.arrayAsListOfString(getDefaultValueOptionsAsJsArray());
	}

	public native JsArrayString getDefaultValueOptionsAsJsArray()/*-{
		return this.defaultValueOptions;
	}-*/;

	@Override
	public native boolean isEphemeral() /*-{
		return this.ephemeral;
	}-*/;

	@Override
	public native String getDataType() /*-{
		return this.dataType;
	}-*/;

	@Override
	public native boolean isSortable()  /*-{
		return this.sortable;
	}-*/;


}
